package com.example.dell.fastshopping.user.modle;

import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;

import com.example.dell.fastshopping.network.ApiService;
import com.example.dell.fastshopping.network.NetCallback;
import com.example.dell.fastshopping.network.RetrofitClient;
import com.example.dell.fastshopping.network.http.BaseResponse;
import com.example.dell.fastshopping.user.entity.UserInfo;

import java.util.ArrayList;
import java.util.List;

public class EnsureMoneyActivityViewModel extends ViewModel {
    private ApiService service = RetrofitClient.getInstance().create(ApiService.class);
    private MutableLiveData<BaseResponse> allmoney = new MutableLiveData<>();
    private MutableLiveData<List<UserInfo.Amounts>> marginType = new MutableLiveData<>();
    private MutableLiveData<BaseResponse> moneyHistory = new MutableLiveData<>();

    public List<String> getList() {
        ArrayList<String> objects = new ArrayList<>();
        objects.add("");
        objects.add("");
        return objects;
    }

    public MutableLiveData<BaseResponse> getMyAllMoney() {
        RetrofitClient.execute(service.getMyAllMoney(), new NetCallback<BaseResponse>() {
            @Override
            public void netCallback(BaseResponse response) {
                allmoney.setValue(response);
            }
        });
        return allmoney;
    }

    public MutableLiveData<List<UserInfo.Amounts>> getMarginType() {
        RetrofitClient.execute(service.getMarginType(), new NetCallback<BaseResponse<List<UserInfo.Amounts>>>() {
            @Override
            public void netCallback(BaseResponse<List<UserInfo.Amounts>> response) {
                marginType.setValue(response.getData());
            }
        });
        return marginType;
    }

    public MutableLiveData<BaseResponse> getMoneyHistory(int pageNum,int pageSize ) {
        RetrofitClient.execute(service.getEnsureMoneyHistory(pageNum, pageSize), new NetCallback<BaseResponse>() {
            @Override
            public void netCallback(BaseResponse response) {
                moneyHistory.setValue(response);
            }
        });
        return moneyHistory;
    }
}
